package cn.iocoder.yudao.module.jikong.dal.mysql.jkProduct;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.jikong.dal.dataobject.jkProduct.JkProductDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.jikong.controller.admin.jkProduct.vo.*;

/**
 * 疾控产品表 Mapper
 *
 * @author admin
 */
@Mapper
public interface JkProductMapper extends BaseMapperX<JkProductDO> {

    default PageResult<JkProductDO> selectPage(JkProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<JkProductDO>()
                .likeIfPresent(JkProductDO::getProductId, reqVO.getProductId())
                .likeIfPresent(JkProductDO::getName, reqVO.getName())
                .eqIfPresent(JkProductDO::getTypeId, reqVO.getTypeId())
                .eqIfPresent(JkProductDO::getStatus, reqVO.getStatus())
                .eqIfPresent(JkProductDO::getPicture, reqVO.getPicture())
                .eqIfPresent(JkProductDO::getDetail, reqVO.getDetail())
                .eqIfPresent(JkProductDO::getProjectId, reqVO.getProjectId())
                .eqIfPresent(JkProductDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(JkProductDO::getResourceId, reqVO.getResourceId())
                .betweenIfPresent(JkProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(JkProductDO::getId));
    }

    default List<JkProductDO> selectHot() {
        return selectList(new LambdaQueryWrapperX<JkProductDO>()
                .orderByDesc(JkProductDO::getClickCount));
    }

    default List<JkProductDO> selectRecommend() {
        return selectList(new LambdaQueryWrapperX<JkProductDO>()
                .orderByDesc(JkProductDO::getId)
                .orderByDesc(JkProductDO::getClickCount)
        );
    }


}
